﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace ALEXFW.Migrations
{
    public partial class Entity1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Exercises",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Name = table.Column<string>(nullable: false),
                    GroupID = table.Column<Guid>(nullable: false),
                    Issuser = table.Column<Guid>(nullable: false),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    EndTime = table.Column<DateTime>(nullable: false),
                    PublishStatus = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Exercises", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ExerciseScores",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExerciseID = table.Column<Guid>(nullable: false),
                    TopicID = table.Column<Guid>(nullable: false),
                    StudentID = table.Column<Guid>(nullable: false),
                    Score = table.Column<double>(nullable: false),
                    Answer = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ExerciseScores", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TopicRepositories",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Name = table.Column<string>(nullable: false),
                    ExerciseID = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TopicRepositories", x => x.Id);
                });

            migrationBuilder.AddColumn<int>(
                name: "Quota",
                table: "Groups",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "PhoneNumber",
                table: "Students",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<DateTime>(
                name: "StartInternshipTime",
                table: "Students",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AlterColumn<int>(
                name: "ApplyStatus",
                table: "ApplyRecords",
                nullable: false,
                oldClrType: typeof(bool),
                oldType: "bit");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Exercises");

            migrationBuilder.DropTable(
                name: "ExerciseScores");

            migrationBuilder.DropTable(
                name: "TopicRepositories");

            migrationBuilder.DropColumn(
                name: "CreateTime",
                table: "Exercises");

            migrationBuilder.DropColumn(
                name: "Quota",
                table: "Groups");

            migrationBuilder.DropColumn(
               name: "PhoneNumber",
               table: "Students");

            migrationBuilder.DropColumn(
                name: "StartInternshipTime",
                table: "Students");

            migrationBuilder.AlterColumn<bool>(
                name: "ApplyStatus",
                table: "ApplyRecords",
                type: "bit",
                nullable: false,
                oldClrType: typeof(int));
        }
    }
}
